home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 80 / XENIATGM80.iso / Goodies / Blood 2 / Source / data.z / MenuBloodBath.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-02  |  3.4 KB  |  131 lines

  1. // MenuBloodBath.cpp: implementation of the CMenuBloodBath class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4.  
  5. #include "MainMenus.h"
  6. #include "MenuCommands.h"
  7. #include "MenuBloodBath.h"
  8. #include "BloodClientShell.h"
  9. #include "VKDefs.h"
  10. #include "ClientRes.h"
  11.  
  12. //////////////////////////////////////////////////////////////////////
  13. // Construction/Destruction
  14. //////////////////////////////////////////////////////////////////////
  15.  
  16. CMenuBloodBath::CMenuBloodBath()
  17. {
  18.  
  19. }
  20.  
  21. CMenuBloodBath::~CMenuBloodBath()
  22. {
  23.  
  24. }
  25.  
  26. // Builds the menu
  27. void CMenuBloodBath::Build()
  28. {
  29.     // Make sure to call the base class
  30.     CMenuBase::Build();
  31.  
  32.     CreateTitle("interface\\mainmenus\\bloodbath.pcx", IDS_MENU_TITLE_BLOODBATH, m_pMainMenus->GetTitlePos());        
  33.     SetOptionPos(m_pMainMenus->GetOptionsPos());
  34.     SetItemSpacing(0);
  35.  
  36.     AddLargeTextItemOption(IDS_MENU_BLOODBATH_JOIN, MENU_CMD_JOIN_GAME);
  37.     AddLargeTextItemOption(IDS_MENU_BLOODBATH_HOST, MENU_CMD_HOST_GAME);
  38.     AddLargeTextItemOption(IDS_MENU_BLOODBATH_CHARSETUP, MENU_CMD_CHARACTER_SETUP_RESVERIFY);
  39. }
  40.  
  41. // Verifies that the current resolution is high enough for the character setup screen
  42. void CMenuBloodBath::DoResolutionVerify()
  43. {
  44.     RMode currentMode;
  45.     m_pClientDE->GetRenderMode(¤tMode);
  46.  
  47.     if (currentMode.m_Width < 640 || currentMode.m_Height < 480)
  48.     {
  49.         // Display a message box asking if they would like to switch resolutions
  50.         m_pMainMenus->DoMessageBox(IDS_MENU_MESSAGE_ASK_CHANGE_RESOLUTION, this);
  51.         m_pMainMenus->AddMessageKey(m_pMainMenus->GetYesVKeyCode(), MENU_CMD_CHARACTER_SETUP_SWITCH_RUN);
  52.         m_pMainMenus->AddMessageKey(m_pMainMenus->GetNoVKeyCode(), MENU_CMD_KILL_MESSAGEBOX);
  53.         m_pMainMenus->AddMessageKey(VK_ESCAPE, MENU_CMD_KILL_MESSAGEBOX);
  54.     }
  55.     else
  56.     {
  57.         // Tell the character setup screen not to ask about switching resolutions back
  58.         m_pMainMenus->GetCharacterSetup()->SetResolutionSwitch(DFALSE, 640, 480);
  59.  
  60.         SendCommand(MENU_CMD_CHARACTER_SETUP, 0, 0);
  61.     }
  62. }
  63.  
  64. // Switches video resolutions to 640x480
  65. DBOOL CMenuBloodBath::SwitchTo640x480()
  66. {    
  67.     RMode currentMode;
  68.     m_pClientDE->GetRenderMode(¤tMode);
  69.     int nOldScreenWidth=currentMode.m_Width;
  70.     int nOldScreenHeight=currentMode.m_Height;
  71.  
  72.     if (!m_pMainMenus->SwitchResolution(640, 480))
  73.     {
  74.         m_pMainMenus->DoMessageBox(IDS_MENU_MESSAGE_RES_CHANGE_ERROR, this);
  75.         m_pMainMenus->AddMessageKey(VK_RETURN, MENU_CMD_KILL_MESSAGEBOX);
  76.         
  77.         return DFALSE;
  78.     }
  79.  
  80.     // Tell the character setup screen to ask about switching resolutions back
  81.     m_pMainMenus->GetCharacterSetup()->SetResolutionSwitch(DTRUE, nOldScreenWidth, nOldScreenHeight);
  82.  
  83.     return DTRUE;
  84. }
  85.  
  86. DDWORD CMenuBloodBath::OnCommand(DDWORD dwCommand, DDWORD dwParam1, DDWORD dwParam2)
  87. {
  88.     switch (dwCommand)
  89.     {
  90.     case MENU_CMD_HOST_GAME:
  91.         {
  92.             g_pBloodClientShell->MenuHostGame();
  93.             break;
  94.         }
  95.     case MENU_CMD_JOIN_GAME:
  96.         {
  97.             g_pBloodClientShell->MenuJoinGame();
  98.             break;
  99.         }
  100.     case MENU_CMD_CHARACTER_SETUP_RESVERIFY:
  101.         {
  102.             DoResolutionVerify();
  103.             break;
  104.         }
  105.     case MENU_CMD_KILL_MESSAGEBOX:
  106.         {
  107.             m_pMainMenus->KillMessageBox();
  108.             break;
  109.         }
  110.     case MENU_CMD_CHARACTER_SETUP_SWITCH_RUN:
  111.         {
  112.             m_pMainMenus->KillMessageBox();
  113.             if (SwitchTo640x480())
  114.             {
  115.                 m_pMainMenus->SetCurrentMenu(MENU_ID_CHARACTER);
  116.             }
  117.             break;
  118.         }
  119.     case MENU_CMD_CHARACTER_SETUP:
  120.         {            
  121.             m_pMainMenus->SetCurrentMenu(MENU_ID_CHARACTER);
  122.             break;
  123.         }
  124.     default:
  125.         {
  126.             assert(DFALSE);
  127.             break;
  128.         }
  129.     }
  130.     return 0;
  131. }